package com.zwu.controller;

import com.zwu.pojo.Student;
import com.zwu.pojo.SuccessVo;
import com.zwu.pojo.Tip;
import com.zwu.service.StudentService;
import com.zwu.service.TipService;
import com.zwu.util.ResultVoUtil;
import com.zwu.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: Zyl
 * @Param:
 * @return:
 * @Description:
 */
@RestController
@RequestMapping("/result")
public class StudentController {
    @Autowired
    StudentService studentService;
    @Autowired
    TipService tipService;


    @GetMapping("/commit/{identify}")
    public ResultVo commit(@PathVariable("identify") String identify){
        if (identify==""){
            return ResultVoUtil.fail("请不要为空");
        }

        Student student = studentService.findStatus(identify);
        if(student==null){
            Student student2=new Student();
            student2.setStatus(0);
            Tip fail = tipService.findFail();
            return ResultVoUtil.fail(fail);
        }
        Tip success = tipService.findSuccess();
        SuccessVo sucessVo=new SuccessVo(success.getFirst(),success.getMid(),success.getLast(),student.getName(),student.getDept());
        return ResultVoUtil.success(sucessVo);
    }
}
